/*-
 * Copyright (c) 2014 Shang-Rong Cai. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $ itermth.h    Rev. 0.1.1    2014-05-29T10:53+08:00 $
 */

#include <stdlib.h>
#include <pregrid.h>

#ifndef ITERMTH_H
#define ITERMTH_H

int vector_set_zeros(size_t length, double *vec);

int vector_stdout(size_t length, double *vec);

int vector_copy(size_t length, const double *vec_x, double *vec_y);

/* Compute Vector (Array) Difference of Components: vec_vz = vec_vx - vec_vy */
int vector_diff(const size_t length, const double *vec_vx, const double *vec_vy, double *vec_vz);

double vector_dot_vector(const size_t length, const double *vec_vx, const double *vec_vy);

double vector_norm2(const size_t length, const double *vec_vx);

int vector_scale_copy(const size_t length, const double *vec_x, const double cof, double *vec_y);


/* Stationary Iterative Method */

/* (Weighted) Jacobi Iteration */
int jacobi_cidk(const cidk_t *cidk, const double *vrhs, const int max_iter, const double atol, const double rtol, const double omega, double *vsol, int *iter);


/* Gauss Seidel Iteration */
/* Successive Over-Relaxation Iteration */
int sor_cidk(const cidk_t *cidk, const double *vrhs, const int max_iter, const double atol, const double rtol, const double omega, double *vsol, int *iter);

#endif
